package com.tyk.bookstore.front.payment.controller;


import com.tyk.bookstore.front.common.core.model.result.R;
import com.tyk.bookstore.front.payment.model.query.AmountLogPageQuery;
import com.tyk.bookstore.front.payment.model.vo.AmountLogPageVo;
import com.tyk.bookstore.front.payment.model.vo.AmountLogVo;
import com.tyk.bookstore.front.payment.service.AmountLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tyk
 * @description 系统余额变更日志
 */
@Tag(name = "支付管理/系统余额变更日志管理", description = "系统余额变更日志管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("api/payment/amount-log")
public class AmountLogController {

    private final AmountLogService amountLogService;

    @Operation(summary = "查询系统余额变更日志详情", description = "查询系统余额变更日志详情")
    @GetMapping("{id}")
    public R<AmountLogVo> getById(
            @Schema(description = "系统余额变更日志ID")
            @NotNull @Min(value = 1)
            @PathVariable Long id
    ) {
        return R.ok(amountLogService.getById(id));
    }

    @Operation(summary = "分页查询系统余额变更日志", description = "分页查询系统余额变更日志")
    @GetMapping("page")
    public R<AmountLogPageVo> getPage(
            @Schema(description = "系统余额变更日志分页查询参数")
            @ParameterObject
            @Validated AmountLogPageQuery query
    ) {
        return R.ok(amountLogService.getPage(query));
    }
}

